const { resolve } = require("path");
const { defineConfig } = require("vite");
import obfuscator from "rollup-plugin-obfuscator";

console.log(__dirname);

module.exports = defineConfig({
  base: "./", // 这里更改打包相对绝对路径
  build: {
    rollupOptions: {
      input: {
        index: resolve(__dirname, "index.html"),
        page2: resolve(__dirname, "page2.html"),
      },
      plugins2: [
        obfuscator({
          // compact: true,
          controlFlowFlattening: true,
          controlFlowFlatteningThreshold: 1,
          deadCodeInjection: true,
          deadCodeInjectionThreshold: 1,
          debugProtection: true,
          debugProtectionInterval: 0,
          disableConsoleOutput: true,
          identifierNamesGenerator: "hexadecimal",
          log: false,
          renameGlobals: false,
          rotateStringArray: true,
          selfDefending: true,
          shuffleStringArray: true,
          splitStrings: true,
          splitStringsChunkLength: 10,
          stringArray: true,
          stringArrayEncoding: ["rc4"],
          stringArrayThreshold: 1,
          transformObjectKeys: true,
          unicodeEscapeSequence: false,
        }),
      ],
    },
  },
});
